package com.shadow.disnet.disrutor;

import com.shadow.disnet.netty.ILog;
import io.netty.channel.Channel;

public class MessageWorker implements MessageProducer<String>, ILog {

    private Channel channel;
    private DisruptorExecutor executor;

    public MessageWorker(Channel channel) {
        this.channel = channel;
    }

    public Channel getChannel() {
        return channel;
    }

    public void setChannel(Channel channel) {
        this.channel = channel;
    }

    public DisruptorExecutor getExecutor() {
        return executor;
    }

    public void setExecutor(DisruptorExecutor executor) {
        this.executor = executor;
    }

    @Override
    public void onMessage(int moduleID, int msgId, String byteBuf) {
        info("moduleID=%s,msgId==%s,msg=%s",moduleID,msgId, byteBuf);
        sendMessage(byteBuf);
    }

    public void sendMessage(String byteBuf) {
        channel.writeAndFlush(byteBuf);
    }
}
